import React,{Component} from 'react';
import {connect} from 'react-redux';
import actions from '../../store/actions/home';
class Home extends Component{
	componentDidMount() {
		this.props.getHomeList();
	}
	render() {
		return (
			<div className="row">
				<div className="col-md-12">
					<ul className="list-group">
						{
							this.props.list.map(item => (
								<li className="list-group-item" key={item.id}>{item.name}</li>
							))
						}
					</ul>
				</div>
			</div>
		)
	}
}

let ConnectedHome = connect(
	state => state.home,
	actions
)(Home);

ConnectedHome.loadData=(store) => {
	//dispatch方法的返回值是action
	//https://github.com/reduxjs/redux/blob/master/src/createStore.js
	return store.dispatch(actions.getHomeList());
}
export default ConnectedHome;